home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F27962_SortMultiKey.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2001-10-04  |  3.3 KB  |  103 lines

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!-- ===========================================================
  3.   Category:       XSLT
  4.   Sub-category:   xsl:sort
  5.   Author:         David Silverlight
  6.                   HeadGeek@xmlpitstop.com
  7.   Created:        2001-05-16
  8.   Description:-
  9.     This stylesheet demonstrates the use of xsl:sort by sorting
  10.     Employee Information with Multi-part Keys.
  11.  =============================================================== -->
  12. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  13.   <xsl:output method="html" />
  14.  
  15.   <xsl:template match="/">
  16.     <html>
  17.       <head>
  18.         <title>Stylesheet Example</title>
  19.         <style type="text/css"><![CDATA[
  20.         H1 {COLOR: red; FONT-FAMILY: Arial; FONT-SIZE: 14pt;}
  21.         H2 {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
  22.         .head {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 14pt;}
  23.         .subhead {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
  24.         .text {COLOR: black; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
  25.         TH {COLOR: white; FONT-FAMILY: Arial; background-color: darkblue;}
  26.         TD {COLOR: darkblue; FONT-FAMILY: Arial}
  27.         TR { background-color: beige; }
  28.         BODY { background-color: beige; }
  29.         ]]></style>
  30.       </head>
  31.       <body>
  32.         <xsl:apply-templates />
  33.       </body>
  34.     </html>
  35.   </xsl:template>
  36.  
  37.   <xsl:template match="employees">
  38.     <h1>Sorting Employees by StartDate then by Hourly Rate within Department</h1>
  39.     <table border="1">
  40.       <tr>
  41.         <th>Name</th>
  42.         <th>Department</th>
  43.         <th>Hourly Rate</th>
  44.         <th>Start Date</th>
  45.         <th>Primary Language</th>
  46.       </tr>
  47.       <xsl:for-each select="employee">
  48.         <xsl:sort order="ascending" select="department" />
  49.         <xsl:sort order="ascending" select="hourlyrate" data-type="number" />
  50.         <tr>
  51.           <td>
  52.             <xsl:value-of select="employeename" />
  53.           </td>
  54.           <td>
  55.             <xsl:value-of select="department" />
  56.           </td>
  57.           <td>
  58.             <xsl:value-of select="hourlyrate" />
  59.           </td>
  60.           <td>
  61.             <xsl:value-of select="startdate" />
  62.           </td>
  63.           <td>
  64.             <xsl:value-of select="primarylanguage" />
  65.           </td>
  66.         </tr>
  67.       </xsl:for-each>
  68.     </table>
  69.     <br />
  70.     <br />
  71.     <h1>Sorting Employees by StartDate then by Hourly Rate within Department(descending)</h1>
  72.     <table border="1">
  73.       <tr>
  74.         <th>Name</th>
  75.         <th>Department</th>
  76.         <th>Hourly Rate</th>
  77.         <th>Start Date</th>
  78.         <th>Primary Language</th>
  79.       </tr>
  80.       <xsl:for-each select="employee">
  81.         <xsl:sort order="ascending" select="department" />
  82.         <xsl:sort order="descending" select="hourlyrate" data-type="number" />
  83.         <tr>
  84.           <td>
  85.             <xsl:value-of select="employeename" />
  86.           </td>
  87.           <td>
  88.             <xsl:value-of select="department" />
  89.           </td>
  90.           <td>
  91.             <xsl:value-of select="hourlyrate" />
  92.           </td>
  93.           <td>
  94.             <xsl:value-of select="startdate" />
  95.           </td>
  96.           <td>
  97.             <xsl:value-of select="primarylanguage" />
  98.           </td>
  99.         </tr>
  100.       </xsl:for-each>
  101.     </table>
  102.   </xsl:template>
  103. </xsl:stylesheet>